package com.efast.cafe.util.jxl;


import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.UnderlineStyle;
import jxl.format.VerticalAlignment;
import jxl.write.Colour;
import jxl.write.NumberFormat;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WriteException;


public final class CellFormatUtil {
	
	//杯题样式格式
	public static  WritableCellFormat getTitleCellFormat(){
		WritableCellFormat cellFormat=new WritableCellFormat();
				try{
					cellFormat.setAlignment(Alignment.CENTRE);
					cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
					cellFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN);
					cellFormat.setBackground(Colour.BLUE_GREY);
				} catch (WriteException e) {
					e.printStackTrace();
				}
		return cellFormat;
	}
	//一般值格式样式
	public static WritableCellFormat getCellValueFormat(){
		WritableCellFormat cellFormat=new WritableCellFormat();
				try{
					cellFormat.setAlignment(Alignment.CENTRE);
					cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
					cellFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN);
				} catch (WriteException e) {
					e.printStackTrace();
				}
		return cellFormat;
	}
	
	 //带红颜色的单元格
	public static WritableCellFormat getCellRedFormat(){
	
    WritableFont font = new WritableFont(WritableFont.ARIAL,10,
            WritableFont.NO_BOLD,false,
            UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.RED); 
  
    WritableCellFormat cellFormat=new WritableCellFormat(font);
		    try {
		    	cellFormat.setAlignment(Alignment.CENTRE);
		    	cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
		    	cellFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN);
			} catch (WriteException e) {
				e.printStackTrace();
			}
    	return cellFormat;
	}
	//带两位小数千位符货币符格式
	public static WritableCellFormat getCellMoneyFormat(){
		NumberFormat numformat = new NumberFormat("￥#,##0.00");
		WritableCellFormat cellFormat=new WritableCellFormat(numformat);
				try{
					cellFormat.setAlignment(Alignment.CENTRE);
					cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
					cellFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN);
				} catch (WriteException e) {
					e.printStackTrace();
				}
		return cellFormat;
	}
	
	//带两位小数千位符格式
	public static WritableCellFormat getCellNUmberFormat(){
		NumberFormat numformat = new NumberFormat("#,##0.00");
		WritableCellFormat cellFormat=new WritableCellFormat(numformat);
				try{
					cellFormat.setAlignment(Alignment.RIGHT);
//					cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
//					cellFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN);
				} catch (WriteException e) {
					e.printStackTrace();
				}
		return cellFormat;
	}
	
	//带两位小数千位符格式
		public static WritableCellFormat getCellIntNumberFormat(){
			NumberFormat numformat = new NumberFormat("#,##0");
			WritableCellFormat cellFormat=new WritableCellFormat(numformat);
					try{
						cellFormat.setAlignment(Alignment.RIGHT);
//						cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
//						cellFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN);
					} catch (WriteException e) {
						e.printStackTrace();
					}
			return cellFormat;
		}
	
	//带两位小数千位符格式
	public static WritableCellFormat getCellNumberFormatPer(){
		NumberFormat numformat = new NumberFormat("0.00%");
		WritableCellFormat cellFormat=new WritableCellFormat(numformat);
				try{
					cellFormat.setAlignment(Alignment.LEFT);
//					cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
//					cellFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN);
				} catch (WriteException e) {
					e.printStackTrace();
				}
		return cellFormat;
	}
	
	//带两位小数的百分比
	public static WritableCellFormat getCellPercentageFormat(){
		NumberFormat numformat = new NumberFormat("##.##%");
		WritableCellFormat cellFormat=new WritableCellFormat(numformat);
				try{
					cellFormat.setAlignment(Alignment.CENTRE);
					cellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);
					cellFormat.setBorder(Border.ALL, jxl.format.BorderLineStyle.THIN);
				} catch (WriteException e) {
					e.printStackTrace();
				}
		return cellFormat;
	}
	
	
}
